package org.jsbd.boss.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IDouyingActionConfigDao;
import org.jsbd.boss.domian.DouyingActionConfig;
import org.jsbd.boss.service.IDouyingActionConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("douyingActionConfigService")
public class DouyingActionConfigServiceImpl implements IDouyingActionConfigService { 
	@Autowired
	private IDouyingActionConfigDao douyingActionConfigDao;
	
	@Override
	public Map<String, Object> getListPage(DataGridModel page, DouyingActionConfig douyingActionConfig) {
		douyingActionConfig = (douyingActionConfig == null ? new DouyingActionConfig() : douyingActionConfig);
		douyingActionConfig.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("total", douyingActionConfigDao.getListPageCount(douyingActionConfig));
		
		List<DouyingActionConfig> list = (List<DouyingActionConfig>) douyingActionConfigDao.getList(douyingActionConfig);
		for (DouyingActionConfig config : list) {
			config.setCreateDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(config.getCreateTime()));
			config.setModifyDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(config.getModifyTime()));
		}
		results.put("rows", list);
		return results;
	}

	@Override
	public void save(DouyingActionConfig douyingActionConfig) {
		douyingActionConfigDao.insert(douyingActionConfig);
		
	}

	@Override
	public void update(DouyingActionConfig douyingActionConfig) {
		douyingActionConfigDao.update(douyingActionConfig);
		
	}

	@Override
	public void delete(List<Integer> ids) {
		douyingActionConfigDao.delete(ids);
	}

}
